<%@page contentType="text/html" import="dbmanager.*,utility.*,java.io.*,guireportgenerator.*"%>
<%@page pageEncoding="UTF-8"%>
<%!
 String htmltext = "";
%>
<%
    try
    {
	    GetIdName get = new GetIdName();
	    String username = (String)session.getAttribute("username");
	    System.out.println(username);
	    String ReportID = (String)session.getAttribute("objectname");
	    System.out.println(ReportID);
	    
	    RequestHandler reqhand = new RequestHandler();
	    reqhand.setUsername(username);
	    reqhand.setRequestPage(ReportID);
	    reqhand.setMaster("");
	    reqhand.isUrl();
	    
	    String ReportData = reqhand.getHtml();
	    System.out.println(ReportData);
	    
	    htmltext = ReportData.replace('\"','\'');	    	    
    }
    catch(NullPointerException e)
    {
        //e.printStackTrace();
    }
%>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>Edit Page</title>
 <link rel="stylesheet" type="text/css" href="../examples/full_example.css" />   
   <script type="text/javascript">
    function showError( sMsg, sUrl, sLine)
    {
           return false;
    }
   	
    _editor_url  = document.location.href.replace(/examples\/EditJsp\.jsp.*/, '')
    //moved _editor_lang & _editor_skin to init function because of error thrown when frame document not ready
  	</script>
	
  <!-- Load up the actual editor core -->
  <script type="text/javascript" src="../XinhaCore.js"></script>
 
  <script type="text/javascript">
    xinha_editors = null;
    xinha_init    = null;
    xinha_config  = null;
    xinha_plugins = null;

    xinha_init = xinha_init ? xinha_init : function() {
      window.onerror = showError;
      document.onerror = showError;

      // var f = top.frames["menu"].document.forms["fsettings"];
       _editor_lang = "en";// f.lang[f.lang.selectedIndex].value; // the language we need to use in the editor.
       // alert("Lang is "+_editor_lang);
       _editor_skin = "blue-metallic"; // "blue-metallic"; // f.skin[f.skin.selectedIndex].value; // the skin we use in the editor
       // alert("Skin is "+_editor_skin);
       _editor_css = "dynamic.css";//"full_example.css";
// What are the plugins you will be using in the editors on this page.
// List all the plugins you will need, even if not all the editors will use all the plugins.
      	xinha_plugins = [ ];
      	xinha_plugins.push("Abbreviation");
      	xinha_plugins.push("BackgroundImage");
      	//xinha_plugins.push("CharacterMap");
      	//xinha_plugins.push("CharCounter");
      	xinha_plugins.push("ClientsideSpellcheck");
      	//xinha_plugins.push("ContextMenu");
      	//xinha_plugins.push("CSS");
      	xinha_plugins.push("DefinitionList");
      	// xinha_plugins.push("DoubleClick");
      	xinha_plugins.push("DynamicCSS");
      	xinha_plugins.push("EditTag");
      	xinha_plugins.push("Equation");
      	xinha_plugins.push("FindReplace");
      	xinha_plugins.push("FormOperations");
      	xinha_plugins.push("Forms");
      	// xinha_plugins.push("FullPage");
      	xinha_plugins.push("GetHtml");
      	//xinha_plugins.push("HorizontalRule");
      	xinha_plugins.push("HtmlEntities");
      	//xinha_plugins.push("htmltemplate");
      	xinha_plugins.push("ImageManager");
      	xinha_plugins.push("InsertAnchor");
      	xinha_plugins.push("InsertMarquee");
      	xinha_plugins.push("InsertPagebreak");
      	xinha_plugins.push("InsertPicture");
      	xinha_plugins.push("LangMarks");
      	xinha_plugins.push("ListType");
      	//xinha_plugins.push("NoteServer");
      	// xinha_plugins.push("PasteText");
      	xinha_plugins.push("QuickTag");
      	xinha_plugins.push("SaveSubmit");
      	xinha_plugins.push("SmartReplace");
      	xinha_plugins.push("SpellChecker");
      	xinha_plugins.push("SuperClean");
      	xinha_plugins.push("TableOperations");
      	xinha_plugins.push("Template");
      	xinha_plugins.push("UnFormat");
      	
// THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
      if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;

// What are the names of the textareas you will be turning into editors?
      var num = 1;
      // num = parseInt(f.num.value);
      // if(isNaN(num)) {
       // num = 1;
        // f.num.value = 1;
      // }
      
      var dest = document.getElementById("editors_here");
      var lipsum =  document.getElementById('htmltext').value; // window.parent.menu.document.getElementById('myTextarea0').value;
		xinha_editors = [ ]
      // for(var x = 0; x < num; x++) {
        // var ta = 'myTextarea' + x;
        var ta = 'myTextarea' + 0;
        xinha_editors.push(ta);
		var div = document.createElement('div');
        div.className = 'area_holder';
		
        var txta = document.createElement('textarea');
        txta.id   = ta;
        txta.name = ta;
        txta.value = lipsum;
        txta.style.width="100%";
        txta.style.height="90%";
		
        div.appendChild(txta);
        dest.appendChild(div);
      // }

// Create a default configuration to be used by all the editors.
      // settings = top.frames["menu"].settings;
      xinha_config = new Xinha.Config();
      xinha_config.width = 'auto';// '640px'; // settings.width;
      xinha_config.height = 'auto';// '480px'; // settings.height;
      xinha_config.sizeIncludesBars = 'true';// settings.sizeIncludesBars;
      xinha_config.sizeIncludesPanels = 'false';// settings.sizeIncludesPanels;
      xinha_config.statusBar = 'true';// settings.statusBar;
      xinha_config.htmlareaPaste = 'true';// settings.htmlareaPaste;
      xinha_config.mozParaHandler = 'built-in';// settings.mozParaHandler;
      xinha_config.getHtmlMethod = 'TransformInnerHTML'; // settings.getHtmlMethod;
      xinha_config.undoSteps = '20';// settings.undoSteps;
      xinha_config.undoTimeout = '500';// settings.undoTimeout;
      xinha_config.changeJustifyWithDirection ='true';//  settings.changeJustifyWithDirection;
      xinha_config.fullPage = 'true';// settings.fullPage;
      // xinha_config.pageStyle = settings.pageStyle;
      //xinha_config.baseHref = settings.baseHref;
      xinha_config.expandRelativeUrl = 'true'; // settings.expandRelativeUrl;
      xinha_config.stripBaseHref = 'true'; // settings.stripBaseHref;
      xinha_config.stripSelfNamedAnchors = 'true' ; //settings.stripSelfNamedAnchors;
      xinha_config.only7BitPrintablesInURLs = 'true' ; // settings.only7BitPrintablesInURLs;
      xinha_config.sevenBitClean = 'true' ; // settings.sevenBitClean;
      xinha_config.killWordOnPaste = 'true'; //settings.killWordOnPaste;
      xinha_config.makeLinkShowsTarget = 'false'; // settings.makeLinkShowsTarget;
      xinha_config.flowToolbars = 'false'; // settings.flowToolbars;
      xinha_config.stripScripts = 'false'; // settings.stripScripts;
      // xinha_config.flowToolbars = settings.flowToolbars;
      xinha_config.showLoading = 'true'; // settings.showLoading;
      xinha_config.pageStyleSheets = ["own.css"];

// Create a default configuration for the plugins
      if (typeof CharCounter != 'undefined') {
        xinha_config.CharCounter.showChar = 'true'; // settings.showChar;
        xinha_config.CharCounter.showWord = 'true'; // settings.showWord;
        xinha_config.CharCounter.showHtml = 'true'; // settings.showHtml;
      }
	
      if(typeof CharacterMap != 'undefined') xinha_config.CharacterMap.mode = 'popup'; // settings.CharacterMapMode;
      if(typeof ListType != 'undefined') xinha_config.ListType.mode = 'toolbar'; // settings.ListTypeMode;
      if(typeof CSS != 'undefined') xinha_config.pageStyle = xinha_config.pageStyle + "\n" + "@import url(custom.css);";
      if(typeof DynamicCSS != 'undefined') xinha_config.pageStyle = "@import url(dynamic.css);";
      if(typeof Filter != 'undefined') xinha_config.Filters = ["Word", "Paragraph"];

      if(typeof Stylist != 'undefined') {
        // We can load an external stylesheet like this - NOTE : YOU MUST GIVE AN ABSOLUTE URL
        //  otherwise it won't work!
        xinha_config.stylistLoadStylesheet(document.location.href.replace(/[^\/]*\.html/, 'stylist.css'));

        // Or we can load styles directly
        //xinha_config.stylistLoadStyles('p.red_text { color:red }');

        // If you want to provide "friendly" names you can do so like
        // (you can do this for stylistLoadStylesheet as well)
        //xinha_config.stylistLoadStyles('p.pink_text { color:pink }', {'p.pink_text' : 'Pretty Pink'});
      }

      if(typeof InsertWords != 'undefined') {
        // Register the keyword/replacement list
        var keywrds1 = new Object();
        var keywrds2 = new Object();

        keywrds1['-- Dropdown Label --'] = '';
        keywrds1['onekey'] = 'onevalue';
        keywrds1['twokey'] = 'twovalue';
        keywrds1['threekey'] = 'threevalue';

        keywrds2['-- Insert Keyword --'] = '';
        keywrds2['Username'] = '%user%';
        keywrds2['Last login date'] = '%last_login%';
        xinha_config.InsertWords = {
          combos : [ { options: keywrds1, context: "body" },
                     { options: keywrds2, context: "li" } ]
        }
      }

// First create editors for the textareas.
// You can do this in two ways, either
//   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
// if you want all the editor objects to use the same set of plugins, OR;
//   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
//   xinha_editors['myTextarea0'].registerPlugins(['Stylist']);
//   xinha_editors['myTextarea1'].registerPlugins(['CSS','SuperClean']);
// if you want to use a different set of plugins for one or more of the editors.
      xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);

// If you want to change the configuration variables of any of the editors,
// this is the place to do that, for example you might want to
// change the width and height of one of the editors, like this...
//		xinha_editors['myTextarea0'].config.width  = '640px';
//		xinha_editors['myTextarea0'].config.height = '480px';

// Finally we "start" the editors, this turns the textareas into Xinha editors.
      Xinha.startEditors(xinha_editors);
    }

// javascript submit handler
// this shows how to create a javascript submit button that works with the htmleditor.
    submitHandler = function(formname) {
      var form = document.getElementById(formname);
      // in order for the submit to work both of these methods have to be called.
      form.onsubmit();
		// window.parent.menu.document.getElementById('myTextarea0').value = document.getElementById('myTextarea0').value;
      
      form.submit();
      return true;
    }

      window.onload = xinha_init;
//    window.onunload = Xinha.collectGarbageForIE;
  </script>
</head>
<body>
<input type="hidden" id="htmltext" name="htmltext" value="<%=htmltext%>">
<%
	htmltext = "";
%>
<form id="to_submit" name="to_submit" method="post" action="WebPageRegistrationServlet">
  <div id="editors_here"></div>
  <button type="button" onclick="submitHandler('to_submit');">Submit</button>
  <textarea id="errors" name="errors" style="width:100%; height:10px; background:silver;"></textarea><!-- style="display:none;" -->
</form>
</body>
</html>

